//
//  AddCartVC.m
//  ChineseCollegeStudentsNetwork
//
//  Created by Zheng on 2019/3/23.
//  Copyright © 2019 刘喆. All rights reserved.
//

#import "AddCartVC.h"

@interface AddCartVC ()

@property (nonatomic, strong) UILabel *titleLbl;
@property (nonatomic, strong) UILabel *buyNameLbl;
@property (nonatomic, strong) UILabel *priceLbl;
@property (nonatomic, strong) UILabel *numLbl;
@property (nonatomic, strong) UIButton *goCartBtn;
@property (nonatomic, strong) UIButton *goBuyBtn;


@end

@implementation AddCartVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"纸质杂志购买";
    
    _titleLbl = [[UILabel alloc] init];
    _titleLbl.text = @"商品已成功添加至购物车!";
    _titleLbl.font = [UIFont systemFontOfSize:22];
    _titleLbl.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:_titleLbl];
    [_titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.offset(25);
    }];
    
    
    _buyNameLbl = [[UILabel alloc] init];
    _buyNameLbl.text = _model.title;
    _buyNameLbl.font = [UIFont systemFontOfSize:20];
    _buyNameLbl.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:_buyNameLbl];
    [_buyNameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.equalTo(self.titleLbl.mas_bottom).offset(35);
    }];
    
    _priceLbl = [[UILabel alloc] init];
    _priceLbl.text = [NSString stringWithFormat:@"¥%@",_model.paperCost];
    _priceLbl.font = [UIFont systemFontOfSize:18];
    _priceLbl.textColor = UIColorFromRGBHex(0xfa7a09);
    [self.view addSubview:_priceLbl];
    [_priceLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(-60);
        make.top.equalTo(self.buyNameLbl.mas_bottom).offset(25);
    }];
    
    _numLbl = [[UILabel alloc] init];
    _numLbl.text = @"x1";
    _numLbl.font = [UIFont systemFontOfSize:18];
    _numLbl.textColor = kColorTint;
    [self.view addSubview:_numLbl];
    [_numLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(60);
        make.top.equalTo(self.buyNameLbl.mas_bottom).offset(25);
    }];

    _goCartBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _goCartBtn.backgroundColor = UIColorFromRGBHex(0xfa7a09);
    _goCartBtn.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightRegular];
    _goCartBtn.layer.cornerRadius = 5.0f;
    _goCartBtn.layer.masksToBounds = YES;
    [_goCartBtn setTitle:@"去购物车继续购买" forState:UIControlStateNormal];
    WEAK_SELF
    [[_goCartBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        STRONG_SELF
        //TODO:去购物车
    }];
    [self.view addSubview:_goCartBtn];
    [_goCartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(40);
        make.left.mas_equalTo(25);;
        make.right.equalTo(self.view.mas_centerX).offset(-15);
        make.top.equalTo(self.priceLbl.mas_bottom).offset(30);
    }];

    _goBuyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _goBuyBtn.backgroundColor = kColorTint;
    _goBuyBtn.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightRegular];
    _goBuyBtn.layer.cornerRadius = 5.0f;
    _goBuyBtn.layer.masksToBounds = YES;
    [_goBuyBtn setTitle:@"继续购物" forState:UIControlStateNormal];
    
    [[_goBuyBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        STRONG_SELF
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [self.view addSubview:_goBuyBtn];
    [_goBuyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(40);
        make.right.mas_equalTo(-25);;
        make.left.equalTo(self.view.mas_centerX).offset(15);
        make.top.equalTo(self.priceLbl.mas_bottom).offset(30);
    }];


}



@end
